<template>
  <div>
    <!-- 这是头部（logo  nav   搜索栏） -->
    <header class="header wrap">
      <div class="logo">
        <h1><img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" /></h1>
      </div>
      <div class="nav">
        <ul>
          <li @click="$router.push('/home')" :class="$route.path=='/home'?'active':''">首页</li>
          <li @click="$router.push('/goods')" :class="$route.path=='/goods'?'active':''">全部商品</li>
          <li @click="$router.push('/user')" :class="$route.path.includes('/user')?'active':''">个人中心</li>
          <li @click="$router.push('/order')" :class="$route.path=='/order'?'active':''">我的订单</li>
          <li @click="$router.push('/free')" :class="$route.path=='/free'?'active':''">专属福利</li>
        </ul>
      </div>
      <div class="search">
        <input type="text" placeholder="请输入商品名称" v-model="goodsSearch" @keyup.13="toSearch" />
        <span @click="toSearch" >
          <img
            src="../assets/img/search.png"
            alt=""
            width="15px"
            height="15px"
        /></span>
      </div>
    </header>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goodsSearch:""
    };
  },
  methods: {
    toSearch(){
      // 携带用户输入的信息，跳转到全部商品页面，
      this.$router.push("/goods?keyword="+this.goodsSearch);
      // 清空输入框
      this.goodsSearch=""
    }
  }
};
</script>
 
<style lang = "less" scoped>
@import "../assets/css/global.less";
.header {
  height: 72px;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .nav {
    ul {
      width: 500px;
      display: flex;
      justify-content: space-between;
      li{
        cursor: pointer;
      }
      .active {
          color: @basecolor;
          font-weight: 700;
        }
      
    }
  }
  .search {
    display: flex;
    input {
      width: 214px;
      height: 36px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      text-indent: 15px;
    }
    span {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 50px;
      height: 40px;
      background: @basecolor;
      border-radius: 0px 20px 20px 0px;
      cursor: pointer;
    }
  }
}
</style>